package struts.form;

import java.io.InputStream;
import java.util.Map;

import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import config.Struts_config;

public class ActionListener implements ServletContextListener{

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.println("信息：系统已注销！");
		
	}

	/*
	 * 在servlet初始化时给到struts配置文件信息
	 * @wxc
	 */
	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		//给到struts的配置文件路径
		ServletContext context = arg0.getServletContext();
		String  xmlPath = context.getInitParameter("struts-config");
		String tomcatPath = context.getRealPath("\\");
		
		try {
			Map<String,XmlBean> map = Struts_config.struts_xml(tomcatPath+xmlPath);
			context.setAttribute("struts", map);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("信息：系统已经加载完成！");
		
	}

}
